<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>hvs1</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" />
    <link rel="prev" href="hsboscil.html" title="hsboscil" />
    <link rel="next" href="hvs2.html" title="hvs2" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">hvs1</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="hsboscil.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="hvs2.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="hvs1"></a>
      <div class="titlepage"></div>
      <a id="IndexHvs1" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">hvs1</span>
        </h2>
        <p>hvs1 — 
      Allows one-dimensional Hyper Vectorial Synthesis (HVS) controlled by externally-updated k-variables.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp114770960"></a>
        <h2>Description</h2>
        <p>
      <span class="emphasis"><em>hvs1</em></span> allows one-dimensional Hyper Vectorial Synthesis (HVS) controlled by externally-updated k-variables.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp114772688"></a>
        <h2>Syntax</h2>
        <pre class="synopsis"><span class="command"><strong>hvs1</strong></span> kx, inumParms, inumPointsX, iOutTab, iPositionsTab, iSnapTab [, iConfigTab]</pre>
      </div>
      <div class="refsect1">
        <a id="idp114774800"></a>
        <h2>Initialization</h2>
        <p>
      <span class="emphasis"><em>inumParms</em></span> - number of parameters controlled by the HVS. Each HVS snapshot is made up of inumParms elements.
    </p>
        <p>
      <span class="emphasis"><em>inumPointsX</em></span> - number of points that each dimension of the HVS cube (or square in case of two-dimensional HVS; or line in case of one-dimensional HVS) is made up.
    </p>
        <p>
      <span class="emphasis"><em>iOutTab</em></span> - number of the table receiving the set of output-parameter instant values of the HVS. The total amount of parameters is defined by the <span class="emphasis"><em>inumParms</em></span> argument.
    </p>
        <p>
      <span class="emphasis"><em>iPositionsTab</em></span> – a table filled with the individual positions of snapshots in the HVS matrix (see below for more information).
    </p>
        <p>
      <span class="emphasis"><em>iSnapTab</em></span> – a table filled with all the snapshots. Each snapshot is made up of a set of parameter values. The amount of elements contained in each snapshots is specified by the <span class="emphasis"><em>inumParms</em></span> argument. The set of elements of each snapshot follows (and is adjacent) to the previous one in this table. So the total size of this table should be &gt;= to <span class="emphasis"><em>inumParms</em></span> multiplied the number of snapshots you intend to store for the HVS.
    </p>
        <p>
      <span class="emphasis"><em>iConfigTab</em></span> – (optional) a table containing the behavior of the HVS for each parameter. If the value of <span class="emphasis"><em>iConfigTab</em></span> is zero (default), this argument is ignored, meaning that each parameter is treated with linear interpolation by the HVS. If <span class="emphasis"><em>iConfigTab</em></span> is different than zero, then it must refer to an existing table whose contents are in its turn referring to a particolar kind of interpolation. In this table, a value of -1 indicates that corresponding parameter is leaved unchanged (ignored) by the HVS; a value of zero indicates that corresponding parameter is treated with linear-interpolation; each other values must be integer numbers indicating an existing table filled with a shape which will determine the kind of special interpolation to be used (table-based interpolation).
    </p>
      </div>
      <div class="refsect1">
        <a id="idp114784752"></a>
        <h2>Performance</h2>
        <p>
      <span class="emphasis"><em>kx</em></span> -  these are externally-modified variables which controls the motion of the pointer in the HVS matrix cube (or square or line in case of HVS matrices made up of less than 3 dimensions). The range of these input arguments must be 0 to 1.
    </p>
        <p>
      Hyper Vectorial Synthesis is a technique that allows control of a huge set of parameters by using a simple and global approach. The key concepts of the HVS are:
    </p>
        <p>
      The set of HVS parameters, whose amount is fixed and defined by the <span class="emphasis"><em>inumParms</em></span> argument. During the HVS performance, all these parameters are variant and can be applied to any sound synthesis technique, as well as to any global control for algorithmic composition and any other kind of level. The user must previously define several sets of fixed values for each HVS parameter, each set corresponding to a determinate synthesis configuration. Each set of values is called snapshot, and can be considered as the coordinates of a bound of a multi-dimensional space. The HVS consists on moving a point in this multi-dimensional space (by using a special motion pointer, see below), according and inside the bounds defined by the snapshots. You can fix any amount of HVS parameters (each parameter being a dimension of the multi-dimensional space), even a huge number, the limit only depends on the processing power (and the memory) of your computer and on the complexity of the sound-synthesis you will use.
    </p>
        <p>
      The HVS cube (or square or line). This is the matrix (of 3, 2 or 1 dimensions, according to the hvs opcode you intend to use) of “mainstays” (or pivot) points of HVS. The total amount of pivot-points depends on the value of the <span class="emphasis"><em>inumPointsX</em></span>, <span class="emphasis"><em>inumPointsY</em></span> and <span class="emphasis"><em>inumPointsZ</em></span> arguments. In the case of a 3-dimensional HVS matrix you can define, for instance, 3 points for the X dimension, 5 for the Y dimension and 2 for the Z dimension. In this case, the total number of pivot-points is 3 * 5 * 2 = 30. With this set of pivot points, the cube Is divided into smaller cubed zones each one bounded by eight nearby points. Each point is numbered. The numeral order of these points is enstabilished in the following way: number zero is the first point, number 1 the second and so on. Assuming you are using a 3-dimensional HVS cube having the number of points above mentioned (i.e. 3, 5 and 2 respectively for the X, Y and Z axis), the first point (point zero) is the upper-left-front vertex of the cube, by facing the XY plane of the cube. The second point is the middle point of the upper front edge of the cube and so on. You can refer to the figure below in order to understand how the numeral order of the pivot-points proceeds:
    </p>
        <p>
      For the 2-dimensional HVS, it is the same, by only omitting the rear cube face, so each zone is bounded by 4 pivot-points instead of 8. For the 1-dimensional HVS, the whole thing is even simpler because it is a line with the pivot-points proceeding from left to right. Each point is coupled with a snapshot.
    </p>
        <p>
      Snapshot order, as stored into the <span class="emphasis"><em>iSnapTab</em></span>, can or cannot follow the order of the pivot-points numbers. In fact it is possible to alter this order by means the <span class="emphasis"><em>iPositionsTab</em></span>, a table that remaps the position of each snapshot in relation to the pivot points. The <span class="emphasis"><em>iPositionsTab</em></span> is made up of the positions of the snapshots (contained in the <span class="emphasis"><em>iSnapTab</em></span>) in the two-dimensional grid. Each subsequent element is actually a pointer representing the position in the <span class="emphasis"><em>iSnapTab</em></span>. For example, in a 2-dimensional HVS matrix such as the following (in this case having <span class="emphasis"><em>inumPointsX</em></span> = 3 and <span class="emphasis"><em>inumPointsY</em></span> = 5:
    </p>
        <div class="table">
          <a id="idp114797552"></a>
          <p class="title">
            <strong>Table 9. </strong>
          </p>
          <div class="table-contents">
            <table border="1">
              <colgroup>
                <col />
                <col />
                <col />
              </colgroup>
              <tbody>
                <tr>
                  <td>5</td>
                  <td>7</td>
                  <td>1</td>
                </tr>
                <tr>
                  <td>3</td>
                  <td>4</td>
                  <td>9</td>
                </tr>
                <tr>
                  <td>6</td>
                  <td>2</td>
                  <td>0</td>
                </tr>
                <tr>
                  <td>4</td>
                  <td>1</td>
                  <td>3</td>
                </tr>
                <tr>
                  <td>8</td>
                  <td>2</td>
                  <td>7</td>
                </tr>
              </tbody>
            </table>
          </div>
        </div>
        <br class="table-break" />
        <p>
      These numbers (to be stored in the <span class="emphasis"><em>iSnapTab</em></span> table by using, for instance, the GEN02 function generator) represents the snapshot position within the grid (in this case a 3x5 matrix). So, the first element 5, has index zero and represents the 6th (element zero is the first) snapshot contained in the iSnapTab, the second element 7 represents the 8th element of <span class="emphasis"><em>iSnapTab</em></span> and so on. Summing up, the vertices of each zone (a cubed zone is delimited by 8 vertices; a squared zone by 4 vertices and a linear zone by 2 points) are coupled with a determinate snapshot, whose number is remapped by the <span class="emphasis"><em>iSnapTab</em></span>.
    </p>
        <p>
      Output values of the HVS are influenced by the motion pointer, a point whose position, in the HVS cube (or square or segment) is determined by the <span class="emphasis"><em>kx</em></span>, <span class="emphasis"><em>ky</em></span> and <span class="emphasis"><em>kz</em></span> arguments. The values of these arguments, which must be in the 0 to 1 range, are externally set by the user. The output values, whose amount is equal to the <span class="emphasis"><em>inumParms</em></span> argument, are stored in the <span class="emphasis"><em>iOutTab</em></span>, a table that must be already allocated by the user, and must be at least <span class="emphasis"><em>inumParms</em></span> size. In what way the motion pointer influences the output? Well, when the motion pointer falls in a determinate cubed zone, delimited, for instance, by 8 vertices (or pivot points), we assume that each vertex has associated a different snapshot (i.e. a set of <span class="emphasis"><em>inumParms</em></span> values), well, the output will be the weighted average value of the 8 vertices, calculated according on the distance of the motion pointer from each of the 8 vertices. In the case of a default behavior, when the <span class="emphasis"><em>iConfigTab</em></span> argument is not set, the exact output is calculated by using linear interpolation which is applied to each different parameter of the HVS. Anyway, it is possible to influence this behavior by setting the <span class="emphasis"><em>iConfigTab</em></span> argument to a number of a table whose contents can affect one or more HVS parameters. The <span class="emphasis"><em>iConfigTab</em></span> table elements are associated to each HVS parameter and their values affect the HVS output in the following way:
      </p>
        <div class="itemizedlist">
          <ul class="itemizedlist" style="list-style-type: disc; ">
            <li class="listitem">
              <p>
            If <span class="emphasis"><em>iConfigTab</em></span> is equal to -1, corresponding output is skipped, i.e. the element is not calculated, leaving corresponding element value in the <span class="emphasis"><em>iOutTab</em></span> unchanged;
          </p>
            </li>
            <li class="listitem">
              <p>
            If <span class="emphasis"><em>iConfigTab</em></span> is equal to zero, then the normal HVS output is calculated (by using weighted average of the nearest vertex of current zone where it falls the motion pointer);
          </p>
            </li>
            <li class="listitem">
              <p>
            If <span class="emphasis"><em>iConfigTab</em></span> element is equal to an integer number &gt; zero, then the contents of a table having that number is used as a shape of a table-based interpolation.
          </p>
            </li>
          </ul>
        </div>
        <p>
    </p>
      </div>
      <div class="refsect1">
        <a id="idp114819984"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the hvs1 opcode. It uses the file <a class="ulink" href="examples/hvs1.csd" target="_top"><em class="citetitle">hvs1.csd</em></a>.

      </p>
        <div class="example">
          <a id="idp114821840"></a>
          <p class="title">
            <strong>Example 376. Example of the hvs1 opcode.</strong>
          </p>
          <div class="example-contents">
            <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p>
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
<span class="comment">; Audio out   Audio in    No messages</span>
-odac           -iadc     -d     <span class="comment">;;;RT audio I/O</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>

<span class="ohdr">sr</span><span class="op">=</span>44100
<span class="ohdr">ksmps</span><span class="op">=</span>100
<span class="ohdr">nchnls</span><span class="op">=</span>2
<span class="ohdr">0dbfs</span> <span class="op">=</span> 1

<span class="comment">; Example by Gabriel Maldonado and Andres Cabrera</span>

ginumLinesX <span class="opc">init</span>	16
ginumParms  <span class="opc">init</span>	3


giOutTab	<span class="ohdr">ftgen</span>	5,0,8, <span class="op">-</span>2,      0
giPosTab	<span class="ohdr">ftgen</span>	6,0,32, <span class="op">-</span>2,     3,2,1,0,4,5,6,7,8,9,10, 11, 15, 14, 13, 12
giSnapTab	<span class="ohdr">ftgen</span>	8,0,64, <span class="op">-</span>2,     1,1,1,   2,0,0,  3,2,0,  2,2,2,  5,2,1,  2,3,4,  6,1,7,    0,0,0, \
                              1,3,5,   3,4,4,  1,5,8,  1,1,5,  4,3,2,  3,4,5,  7,6,5,    7,8,9
<span class="opc">tb0_init</span>	giOutTab

        <span class="opc">FLpanel</span>	"hsv1",500,100,10,10,0
gk1,ih1	<span class="opc">FLslider</span> "X", 0,1,  0,5, <span class="op">-</span>1, 400,30, 50,20
        <span class="opc">FLpanel_end</span>
        <span class="opc">FLrun</span>

        <span class="oblock">instr</span>	1
<span class="comment">;               kx,   inumParms,  inumPointsX,  iOutTab,  iPosTab,  iSnapTab  [, iConfigTab] </span>
        <span class="opc">hvs1</span>    gk1,  ginumParms, ginumLinesX, giOutTab, giPosTab, giSnapTab  <span class="comment">;, iConfigTab</span>

k0	<span class="opc">init</span>	0
k1	<span class="opc">init</span>	1
k2	<span class="opc">init</span>	2

<span class="opc">printk2</span>	<span class="opc">tb0</span>(k0)
<span class="opc">printk2</span>	<span class="opc">tb0</span>(k1), 10
<span class="opc">printk2</span>	<span class="opc">tb0</span>(k2), 20

aosc1 <span class="opc">oscil</span> <span class="opc">tb0</span>(k0)<span class="op">/</span>20, <span class="opc">tb0</span>(k1)<span class="op">*</span>100 <span class="op">+</span> 200, 1
aosc2 <span class="opc">oscil</span> <span class="opc">tb0</span>(k1)<span class="op">/</span>20, <span class="opc">tb0</span>(k2)<span class="op">*</span>100 <span class="op">+</span> 200, 1
aosc3 <span class="opc">oscil</span> <span class="opc">tb0</span>(k2)<span class="op">/</span>20, <span class="opc">tb0</span>(k0)<span class="op">*</span>100 <span class="op">+</span> 200, 1
aosc4 <span class="opc">oscil</span> <span class="opc">tb0</span>(k1)<span class="op">/</span>20, <span class="opc">tb0</span>(k0)<span class="op">*</span>100 <span class="op">+</span> 200, 1
aosc5 <span class="opc">oscil</span> <span class="opc">tb0</span>(k2)<span class="op">/</span>20, <span class="opc">tb0</span>(k1)<span class="op">*</span>100 <span class="op">+</span> 200, 1
aosc6 <span class="opc">oscil</span> <span class="opc">tb0</span>(k0)<span class="op">/</span>20, <span class="opc">tb0</span>(k2)<span class="op">*</span>100 <span class="op">+</span> 200, 1

<span class="opc">outs</span> aosc1 <span class="op">+</span> aosc2 <span class="op">+</span> aosc3, aosc4 <span class="op">+</span> aosc5 <span class="op">+</span> aosc6
	<span class="oblock">endin</span>


<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>

<span class="stamnt">f</span>1 0 1024 10 1
<span class="stamnt">f</span>0 3600
<span class="stamnt">i</span>1 0 3600

<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
      </div>
      <div class="refsect1">
        <a id="idp114826128"></a>
        <h2>See Also</h2>
        <p>
      <a class="link" href="hvs2.html" title="hvs2"><em class="citetitle">hvs2</em></a>,
      <a class="link" href="hvs3.html" title="hvs3"><em class="citetitle">hvs3</em></a>,
      <a class="link" href="vphaseseg.html" title="vphaseseg"><em class="citetitle">vphaseseg</em></a>
    </p>
      </div>
      <div class="refsect1">
        <a id="idp114830096"></a>
        <h2>Credits</h2>
        <p>Author: Gabriel Maldonado</p>
        <p>New in version 5.06</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="hsboscil.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="OpcodesTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="hvs2.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">hsboscil </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> hvs2</td>
        </tr>
      </table>
    </div>
  </body>
</html>
